
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><?php echo $title;?></title>
    <!-- 设置缩放 -->
    <meta name="viewport" content="minimal-ui,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <!-- IOS中禁用将数字识别为电话号码/忽略Android平台中对邮箱地址的识别 -->
    <meta name="format-detection" content="telephone=no" />
    <!-- windows phone 点击无高光 -->
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- icon -->
    <link rel="shortcut icon" href="<?php echo ADMIN_ICO_PIC;?>" type="image/x-icon"/>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="<?php echo SYS_LINK;?>admin/css/content.css?v=<?php echo V_CSSJS;?>" />
    <style>
        .form_item .hint .show_pic_btn {margin-bottom: -4px;}
    </style>
</head>
<?php
$info = isset($info) ? $info : array();
?>
<body>
<div class="con_box">
    <div class="titleH18">修改用户</div>
    <form class="form_box" id="imgViewerBox">
        <input type="hidden" name="mould_code" value="<?php echo $mouldCode;?>">
        <input type="hidden" name="menu_id" value="<?php echo $menu_id;?>">
        <input type="hidden" name="id" value="<?php echo isset($info['id']) ? $info['id'] : '0';?>">
        <div class="form_item">
            <label>头像</label>
            <input type="text" name="headimg" id="headimg" class="login_pic filebox_val" value="<?php echo $info['headimg']; ?>" autocomplete="off" placeholder="点击选择"/>
            <i class="hint">
                <img src="<?php echo SYS_LINK;?>admin/img/common/pic.png" class="show_pic_btn" style="<?php $info['headimg'] ? '' : 'display:none;';?>" img_src="<?php echo SYS_LINK.$info['headimg']; ?>"> &nbsp;
                (选填)50×50像素
            </i>
        </div>
        <div class="form_item">
            <label>帐号</label>
            <input type="text" name="title" value="<?php echo isset($info['title']) ? $info['title'] : '';?>" autocomplete="off" placeholder="请输入">
            <i class="hint">* (必填)登录帐号</i>
        </div>
        <div class="form_item">
            <label>密码</label>
            <input type="password" name="pwd" autocomplete="off" placeholder="字母数字组合">
            <i class="hint">* (不填则不修改)</i>
        </div>
        <div class="form_item">
            <label>手机</label>
            <input type="number" name="mobile" value="<?php echo isset($info['mobile']) ? $info['mobile'] : '';?>" autocomplete="off" placeholder="请输入">
            <i class="hint">* (选填)</i>
        </div>
        <div class="form_item">
            <label>邮箱</label>
            <input type="text" name="email" value="<?php echo isset($info['email']) ? $info['email'] : '';?>" autocomplete="off" placeholder="请输入">
            <i class="hint">* (选填)</i>
        </div>
        <div class="form_item" <?php echo !in_array(getUserLevel(),array(1,2)) ? 'style="display:none"' : '';?>>
            <label>等级</label>
            <select name="levels">
                <?php
                foreach(BaseData::$userLevelArr as $k=>$v){
                    echo "<option value=\"$k\">$v</option>";
                }
                ?>
            </select>
            <i class="hint">* (必选)</i>
        </div>
        <div class="form_item" <?php echo !in_array(getUserLevel(),array(1,2)) ? 'style="display:none"' : '';?>>
            <label>角色</label>
            <select name="power_id">
                <?php
                $power_id = isset($info['power_id']) ? $info['power_id'] : '';
                foreach($roleList as $v){
                    $selected = $power_id == $v['id'] ? 'selected="selected"' : '';
                    echo '<option value="'.$v['id'].'" '.$selected.'>'.$v['title'].'</option>';
                }
                ?>
            </select>
            <i class="hint">* (必选)分配权限</i>
        </div>
        <?php echo $fieldItemHtml;?>
        <div class="form_item">
            <label>创建时间</label>
            <input type="text" name="createdate" value="<?php echo isset($info['createdate']) ? $info['createdate'] : '';?>" autocomplete="off" id="createdate" placeholder="请输入">
            <i class="hint">* (选填)默认当前时间</i>
        </div>
        <div class="form_item">
            <label>展示排序</label>
            <input type="number" name="viewseq" value="<?php echo isset($info['viewseq']) ? $info['viewseq'] : '0';?>" autocomplete="off" placeholder="显示排序顺序" class="input100">
            <i class="hint">* (选填)必须正整数，显示排序顺序，越大越靠前，默认0</i>
        </div>
        <div class="form_item">
            <label>内容状态</label>
            <?php
            $status1 = isset($info['status']) && $info['status'] == 1 ? 'checked="checked"' : '';
            $status2 = isset($info['status']) && $info['status'] == 2 ? 'checked="checked"' : '';
            $status3 = isset($info['status']) && $info['status'] == 3 ? 'checked="checked"' : '';
            $status4 = isset($info['status']) && $info['status'] == 4 ? 'checked="checked"' : '';
            ?>
            <label class="radio"><input type="radio" value="1" name="status" <?php echo $status1;?> >正常</label>
            <label class="radio"><input type="radio" value="2" name="status" <?php echo $status2;?> >停用</label>
            <label class="radio"><input type="radio" value="3" name="status" <?php echo $status3;?> >待审</label>
            <label class="radio"><input type="radio" value="4" name="status" <?php echo $status4;?> >注销</label>
            <i class="hint">* (必选)状态</i>
        </div>
        <div class="form_item">
            <label>登录次数</label>
            <span><?php echo isset($info['logincount']) ? $info['logincount'] : '1';?></span>
        </div>
        <div class="form_item">
            <label style="color:#ff7f77"> 编辑需保存 </label>
            <input type="button" id="sub_btn" value="提交保存" class="btn_base btn_back_sides btn_w300 btn_height35 btn_radius5">
        </div>
    </form>
</div>
</body>
<script language="javascript">
    var cssjsv = '<?php echo V_CSSJS;?>';
    var http_url = '<?php echo SYS_HOST;?>';
    var http_link = '<?php echo SYS_LINK;?>';
    var http_fix = '<?php echo SYS_URL_FIX;?>';
</script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/jquery.min.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/skin.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript" src="<?php echo SYS_LINK;?>admin/js/common.js?v=<?php echo V_CSSJS;?>"></script>
<script type="text/javascript">file_load('info');</script>
<script language="javascript">
    var nowDate = '<?php echo date("Y-m-d");?>';
    var gotoUrl = '<?php echo SYS_URL_PATH('admin_user_infoup');?>';
    var picUploadUrl = '<?php echo SYS_URL_PATH('c_upload_base64upload/go/1');?>';
    window.onload = function () {

        <?php echo $fieldItemStyle;?>

        // 图片预览
        var viewer = new Viewer(document.getElementById('imgViewerBox'), {
            url: 'img_src'
        });

        // 颜色选择器
        $('.jscolors').jPicker();

        // 日期
        jeDate({
            dateCell: '#createdate',
            isTime: true,
            format: 'YYYY-MM-DD hh:mm:ss',
            minDate: '2022-06-01',
            maxDate:nowDate
        })

        //头像上传
        $("#headimg").on('click',function (){
            var param = [];
            param['zhl_upload_url'] = picUploadUrl; //上传url,必须
            param['zhl_upload_num'] = 1; 		  //上传数量控制,可选，int 默认1
            param['zhl_upload_size'] = 1024*500;	  //上传大小，int b 默认2M,//500kb
            param['zhl_upload_box'] = '#headimg'; //可选  选择器 上传成功信息盒子
            param['zhl_upload_css'] = 'zhl_upload_css_one';	//可选 默认 zhl_upload_css_one
            //zhl_upload_show(param);
            $('body').zhlUploads(param,function(e){});
        })
    }

    var flagSub = true;
    // 数据提交
    $(function(){
        $('#sub_btn').on('click',function(){
            if(!flagSub){
                layer.msg('处理中……(禁止重复提交)');return false;
            }
            flagSub = false;
            var fromBox = $('.form_box');
            var param = getFormData(fromBox);
            param.append('subFlag', 'Y'); // 追加参数
            $.ajax({
                url:gotoUrl,
                dataType:'json',
                type:'POST',
                async: false,
                data: param,
                processData : false, // 使数据不做处理
                contentType : false, // 不要设置Content-Type请求头
                success: function(data){
                    flagSub = true;
                    if(data=='Y'){
                        layer.msg('编辑成功');
                        setTimeout(function(){
                            parent.location.reload();
                        },2500);
                    }else{
                        layer.msg('操作失败_'+data);
                    }
                },
                error:function(response){
                    flagSub = true;
                    layer.msg('网络异常');
                    console.log('网络异常：'+response);
                }
            });
        })
    })
</script>
</html>